Generating a DataDirect Spy™ Log
When you enable DataDirect Spy for a connection, you can customize DataDirect Spy logging for your needs by setting one or multiple options for DataDirect Spy. See "Tracking JDBC Calls" for information about using DataDirect Spy and instructions on enabling and customizing logging.
Turning On and Off DataDirect Spy™ Logging
Once DataDirect Spy logging is enabled for a connection, you can turn on and off the logging at runtime using the setEnableLogging method in the com.ddtek.jdbc.extensions.ExtLogControl interface. When DataDirect Spy logging is enabled, all Connection objects returned to an application provide an implementation of the ExtLogControl interface.
For example, the following code turns off logging using setEnableLogging(false):
import com.ddtek.jdbc.extensions.* // Get Database Connection Connection con = DriverManager.getConnection ("jdbc:sequelink://QANT:4003;User=TEST;Password=secret; SpyAttributes=(log=(file)/tmp/spy.log"); ((ExtLogControl) con).setEnableLogging(false); ...The setEnableLogging method only turns on and off logging if DataDirect Spy logging has already been enabled for a connection; it does not set or change DataDirect Spy attributes. See "Enabling DataDirect Spy™" for information about enabling and customizing DataDirect Spy logging.
ExtLogControl Class
DataDirect Spy™ Log Example
The following example shows a DataDirect Spy log. The numbers in bold superscript are note indicators that correspond to the notes following the example. They provide explanations for the referenced text to help you understand the content of your own DataDirect Spy logs.
All rights reserved.1 registerDriver:driver[className=com.ddtek.jdbcspy.SpyDriver, context=null,com.ddtek.jdbcspy.SpyDriver@1ec49f]2 *Driver.connect(jdbc:spy:{jdbc:sequelink://QANT:4003;databaseName=Oracle;}) trying driver[className=com.ddtek.jdbcspy.SpyDriver, context=null,com.ddtek.jdbcspy.SpyDriver@1ec49f]3 spy>> Driver.connect(String url, Properties info) spy>> url = jdbc:spy:{jdbc:sequelink://QANT:4003;databaseName=Oracle; OSUser=qauser;OSPassword=null12} spy>> info = {password=tiger, user=scott} spy>> OK (Connection[1])4 getConnection returning driver[className=com.ddtek.jdbcspy.SpyDriver, context=null,com.ddtek.jdbcspy.SpyDriver@1ec49f]5 spy>> Connection[1].getWarnings() spy>> OK6 spy>> Connection[1].createStatement spy>> OK (Statement[1])7 spy>> Statement[1].executeQuery(String sql) spy>> sql = select empno,ename,job from emp where empno=7369 spy>> OK (ResultSet[1])8 spy>> ResultSet[1].getMetaData() spy>> OK (ResultSetMetaData[1])9 spy>> ResultSetMetaData[1].getColumnCount() spy>> OK (3)10 spy>> ResultSetMetaData[1].getColumnLabel(int column) spy>> column = 1 spy>> OK (EMPNO)11 spy>> ResultSetMetaData[1].getColumnLabel(int column) spy>> column = 2 spy>> OK (ENAME)12 spy>> ResultSetMetaData[1].getColumnLabel(int column) spy>> column = 3 spy>> OK (JOB)13 spy>> ResultSet[1].next() spy>> OK (true)14 spy>> ResultSet[1].getString(int columnIndex) spy>> columnIndex = 1 spy>> OK (7369)15 spy>> ResultSet[1].getString(int columnIndex) spy>> columnIndex = 2 spy>> OK (SMITH)16 spy>> ResultSet[1].getString(int columnIndex) spy>> columnIndex = 3 spy>> OK (CLERK)17 spy>> ResultSet[1].next() spy>> OK (false)18 spy>> ResultSet[1].close() spy>> OK19 spy>> Connection[1].close() spy>> OK20NOTES:
1: The Spy driver is registered. The spy>> prefix indicates that this line has been logged by Spy.
2: The JDBC Driver Manager logs a message each time a JDBC driver is registered.
3: This is the logging of the JDBC Driver Manager. It logs a message each time a JDBC application makes a connection.
4: The application connects with the specified URL. The User Name and Password are specified using properties.
5: This is the logging of the JDBC Driver Manager. It logs a message each time a successful connection is made.
6: The application checks to see if there are any warnings. In this example, no warnings are present.
7 and 8: The statement "select empno,ename,job from emp where empno=7369" is created.
9, 10, 11, 12, and 13: Some metadata is requested.
14, 15, 16, and 17: The first row is fetched.
18: The application attempts to fetch the second row, but the database returned only one row for this query.
19: After fetching all data, the result set is closed.
20: The application finishes and disconnects.